package com.fly.studio.home.manage.handler;

import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Floor Handler Factory
 *
 * @author Mr.Fu
 * @date 2022/9/3 下午8:31
 */
@Component
public class FloorHandlerFactory {

    private static final Map<String, FloorHandler> HANDLER_MAP = new HashMap<>(16);

    public FloorHandlerFactory(List<FloorHandler> floorHandlerList) {
        for (FloorHandler floorHandler : floorHandlerList) {
            HANDLER_MAP.put(floorHandler.getClass().getSimpleName(), floorHandler);
        }
    }

    public FloorHandler getHandler(String handlerName) {
        return HANDLER_MAP.get(handlerName);
    }
}
